package com.parenting.controller;


import cn.hutool.core.bean.BeanUtil;
import com.parenting.entities.PlatformUserDO;
import com.parenting.oauth2.AuthUtil;
import com.parenting.request.platform.UpdateLoginUserRequest;
import com.parenting.service.PlatformUserService;
import com.parenting.util.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 平台用户表 前端控制器
 * </p>
 *
 * @author 烟台业达-王世玺
 * @since 2021-10-12
 */
@RestController
@Api(tags = "个人信息")
@RequestMapping("/user")
public class PlatformUserController {

    @Autowired
    private PlatformUserService platformUserService;

    @ApiOperation("修改改个人信息")
    @PutMapping()
    public Result updatePlatformUser(@RequestBody UpdateLoginUserRequest request){
        PlatformUserDO platformUserDO = BeanUtil.copyProperties(request, PlatformUserDO.class);
        platformUserDO.setPlatformUserId(AuthUtil.getUserInfo().getId());
        platformUserService.updateById(platformUserDO);
        return Result.buildSuccess();
    }

}

